
#
# Abstruct class of player
#
class Player
  tune_list: null
  controller: null
  state: null
  # state valiations
  #  'idle' [pub/sub]idle
  #  'playready' [pub]load tune file to play
  #  'playing' [pub]decoding and broadcasting audio data
  #  'requesting' [sub]request tunes for server
  #  'listening' [sub]receiving audio data

  #
  # constructor
  #
  constructor:(@controller)->
    @tune_list = new TuneList()
    @state = 'idle'

  set_state:(status)->
    console.log "player status : #{status}"
    @state = status

  is_publisher:()->
    @state is 'playready' or @state is 'playing'

  is_subscriber:()->
    @state is 'listening'

  #
  # Message Handler : on receive added tune event from server
  #
  add_tune:(tune)->
    # add playlist
    @tune_list.add_tune(tune)

      